#define _CRT_SECURE_NO_WARNINGS 1

#include "Sort.h"
void TestInsertSort()
{
	int a[] = { 9,2,4,5,1,6,7 };
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestQuickSort()
{
	int a[] = { 9,2,4,5,1,6,7 };
	QuickSort(a,0,sizeof(a) / sizeof(int)-1);
	PrintArray(a, sizeof(a) / sizeof(int));
}
void test()
{
	srand(time(0));
	int n = 1000000;
	int* a1 = (int*)malloc(sizeof(int) * n);
	int* a2 = (int*)malloc(sizeof(int) * n);
	int* a3 = (int*)malloc(sizeof(int) * n);
	int* a4 = (int*)malloc(sizeof(int) * n);
	int* a5 = (int*)malloc(sizeof(int) * n);
	int* a6 = (int*)malloc(sizeof(int) * n);
	int* a7 = (int*)malloc(sizeof(int) * n);

	for (int i = 0; i < n; i++)
		a1[i] = rand() + i;

	for (int i = 0; i < n; i++)
	{
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
		a6[i] = a1[i];
		a7[i] = a1[i];
	}

	int begin1 = clock();
	HeapSort(a2, n);
	int end1 = clock();
	printf("HeapSort:%d\n", end1 - begin1);

	int begin2 = clock();
	//InsertSort(a3, n);
	int end2 = clock();
	printf("InsertSort:%d\n", end2 - begin2);

	int begin3 = clock();
	QuickSort(a4, 0, n - 1);
	int end3 = clock();
	printf("QuickSort:%d\n", end3 - begin3);

	int begin4 = clock();
	ShellSort(a5,n);
	int end4 = clock();
	printf("ShellSort:%d\n", end4 - begin4);

	int begin5 = clock();
	MergeSort(a6, n);
	int end5 = clock();
	printf("MergeSort:%d\n", end5 - begin5);

	
	int begin6 = clock();
	CountSort(a7,n);
	int end6 = clock();
	printf("CountSort:%d\n", end6 - begin6);
}
void TestQuickSortrot()
{
	int a[] = { 9,2,4,5,1,6,7 };
	QuickSortrot(a, 0, sizeof(a) / sizeof(int) - 1);
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestQuickSortNOR()
{
	int a[] = { 9,2,4,5,1,6,7 };
	QuickSortNOR(a, 0, sizeof(a) / sizeof(int) - 1);
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestShellSort()
{
	int a[] = { 9,2,4,5,1,6,7 };
	ShellSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

void TestMergeSort()
{
	int a[] = { 9,2,4,5,1,6,7 };
	MergeSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestMergeSortNOR()
{
	int a[] = { 9,2,4,5,1,6,7,8 };
	MergeSortNOR(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestCountSort()
{
	int a[] = { 9,2,4,5,1,6,7,8 };
	CountSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}
int main()
{
	//TestInsertSort();
	//TestQuickSort();
	test();
	/*TestQuickSortrot();*/
	//TestQuickSortNOR();
	//TestShellSort();
	//TestMergeSort();
	//TestMergeSortNOR();
	//TestCountSort();
	return 0;
}